<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 方卡在线 @2010-2014 f02
'URL:http://www.fangka.net/
'EMail:admin@ifangka.com
'QQ:861118936
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0,1",UType)
Call CheckAdminLimit(ULimit,"s_JMail",0)

Dim IsJMail
Dim EMail_Address,EMail_Accouns,EMail_Pwd,EMail_Smtp,EMail_To

If FKFun.IsObjInstalled("JMail.Message") Then
	IsJMail=1
Else
	IsJMail=0
End If

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call JMailBox() '邮件发送设置表单
	Case 2
		Call JMailDo() '邮件发送设置保存
	Case 3
		Call JMailTest() '邮件发送测试
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：JMailBox()
'作    用：邮件发送设置表单
'==========================================
Sub JMailBox()
	'读取选项
	EMail_Address=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Address:","|;|","")
	EMail_Accouns=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Accouns:","|;|","")
	EMail_Pwd=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Pwd:","|;|","")
	EMail_Smtp=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Smtp:","|;|","")
	EMail_To=FKFun.GetSub(Fk_Site_EMailOption,"EMail_To:","|;|","")
%>
<form id="JMailSet" name="JMailSet" method="post" action="JMail.asp?Type=2" target="ajax" boxClose="1" showStr="邮件发送设置成功！">
<div id="title">邮件发送设置</div>
<div id="box">
	<table width="95%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
<%
	If IsJMail=1 Then
%>
        <tr>
            <td height="30" align="right">邮件发送：</td>
            <td>&nbsp;<input type="radio" name="Fk_Site_EMail" class="input" id="Fk_Site_EMail" value="0"<%=FKFun.BeCheck(Fk_Site_EMail,0)%> onclick="$('.JMail').hide();" /> 关闭
				<input type="radio" name="Fk_Site_EMail" class="input" id="Fk_Site_EMail" value="1"<%=FKFun.BeCheck(Fk_Site_EMail,1)%> onclick="$('.JMail').show();" /> 开启<span class="help" title="<p>此功能开启时，有新留言时会发送邮件题型。</p>"></span>
			</td>
        </tr>
        <tr class="JMail">
            <td height="30" align="right">发送邮箱：</td>
            <td>&nbsp;<input name="EMail_Address" type="text" class="input" id="EMail_Address" value="<%=EMail_Address%>" size="40" /><span class="help" title="<p>发送邮件的邮箱，请输入1-50个字符。</p>"></span></td>
        </tr>
        <tr class="JMail">
            <td height="30" align="right">发送邮箱帐号：</td>
            <td>&nbsp;<input name="EMail_Accouns" type="text" class="input" id="EMail_Accouns" value="<%=EMail_Accouns%>" size="40" /><span class="help" title="<p>发送邮件的邮箱帐号，请输入1-50个字符。</p>"></span></td>
        </tr>
        <tr class="JMail">
            <td height="30" align="right">发送邮箱密码：</td>
            <td>&nbsp;<input name="EMail_Pwd" type="password" class="input" id="EMail_Pwd" value="<%=EMail_Pwd%>" size="40" /><span class="help" title="<p>发送邮件的邮箱密码，请输入1-50个字符。</p>"></span></td>
        </tr>
        <tr class="JMail">
            <td height="30" align="right">SMTP服务器：</td>
            <td>&nbsp;<input name="EMail_Smtp" type="text" class="input" id="EMail_Smtp" value="<%=EMail_Smtp%>" size="40" /><span class="help" title="<p>发送邮件的SMTP服务器，请输入1-50个字符。</p>"></span></td>
        </tr>
        <tr class="JMail">
            <td height="30" align="right">接收邮箱：</td>
            <td>&nbsp;<input name="EMail_To" type="text" class="input" id="EMail_To" value="<%=EMail_To%>" size="40" /><span class="help" title="<p>接收邮件的邮箱，请输入1-50个字符。</p>"></span></td>
        </tr>
        <tr class="JMail">
            <td height="30" align="right">测试：</td>
            <td>&nbsp;<a href="javascript:void(0);" onclick="JMailTest();">发送测试邮件</a></td>
        </tr>
<%
	Else
%>
        <tr>
            <td width="18%" height="30" align="right" style="color:#F00;">说明：</td>
            <td width="82%" style="color:#F00;">&nbsp;您的空间不支持JMail组件，邮件发送功能自动关闭！</td>
        </tr>
<%
	End If
%>
	</table>
</div>
<div id="bottom">
<%
	If IsJMail=1 Then
%>
	<input type="submit" class="button" name="Enter" id="Enter" value="设 置" />
<%
	End If
%>
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
	<%If Fk_Site_EMail=0 Then%>
	$('.JMail').hide();
	<%End If%>
});
</script>
<%
End Sub

'==========================================
'函 数 名：JMailDo()
'作    用：邮件发送设置保存
'==========================================
Sub JMailDo()
	Fk_Site_EMail=Trim(Request.Form("Fk_Site_EMail"))
	EMail_Address=FKFun.HTMLEncode(Trim(Request.Form("EMail_Address")))
	EMail_Accouns=FKFun.HTMLEncode(Trim(Request.Form("EMail_Accouns")))
	EMail_Pwd=FKFun.HTMLEncode(Trim(Request.Form("EMail_Pwd")))
	EMail_Smtp=FKFun.HTMLEncode(Trim(Request.Form("EMail_Smtp")))
	EMail_To=FKFun.HTMLEncode(Trim(Request.Form("EMail_To")))
	Call FKFun.JsonNum(Fk_Site_EMail,"请选择是否启用邮件发送功能！")
	If Fk_Site_EMail=1 Then
		Call FKFun.JsonString(EMail_Address,1,50,0,"请输入发送邮件的邮箱！","发送邮件的邮箱不能大于50个字符！")
		Call FKFun.JsonString(EMail_Accouns,1,50,0,"请输入发送邮件的邮箱帐号！","邮件的邮箱帐号不能大于50个字符！")
		Call FKFun.JsonString(EMail_Pwd,1,50,0,"请输入发送邮件的邮箱密码！","发送邮件的邮箱密码不能大于50个字符！")
		Call FKFun.JsonString(EMail_Smtp,1,50,0,"请输入发送邮件的SMTP服务器！","发送邮件的SMTP服务器不能大于50个字符！")
		Call FKFun.JsonString(EMail_To,1,50,0,"请输入收件邮箱！","收件邮箱不能大于50个字符！")
	End If

	Fk_Site_EMailOption=""
	Fk_Site_EMailOption=Fk_Site_EMailOption&"EMail_Address:"&EMail_Address&"|;|"
	Fk_Site_EMailOption=Fk_Site_EMailOption&"EMail_Accouns:"&EMail_Accouns&"|;|"
	Fk_Site_EMailOption=Fk_Site_EMailOption&"EMail_Pwd:"&EMail_Pwd&"|;|"
	Fk_Site_EMailOption=Fk_Site_EMailOption&"EMail_Smtp:"&EMail_Smtp&"|;|"
	Fk_Site_EMailOption=Fk_Site_EMailOption&"EMail_To:"&EMail_To&"|;|"

	Sqlstr="Select Top 1 * From [Fk_Site]"
	Rs.Open Sqlstr,Conn,1,3
	Application.Lock()
	If Not Rs.Eof Then
		'留言邮件功能
		Rs("Fk_Site_EMail")=Fk_Site_EMail
		Rs("Fk_Site_EMailOption")=Fk_Site_EMailOption
		Rs.Update()
	End If
	Application.UnLock()
	Rs.Close
	Call FKFun.JsonSuccess()
End Sub

'==========================================
'函 数 名：JMailTest()
'作    用：邮件发送测试
'==========================================
Sub JMailTest()
	Temp=FKFun.HTMLEncode(Trim(Request.Form("Option")))
	EMail_Address=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Address:","|;|","")
	EMail_Accouns=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Accouns:","|;|","")
	EMail_Pwd=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Pwd:","|;|","")
	EMail_Smtp=FKFun.GetSub(Fk_Site_EMailOption,"EMail_Smtp:","|;|","")
	EMail_To=FKFun.GetSub(Fk_Site_EMailOption,"EMail_To:","|;|","")
	If EMail_Address="" Or EMail_Accouns="" Or EMail_Pwd="" Or EMail_Smtp="" Or EMail_To="" Then
		Call FKFun.ShowErr("参数不全！",2)
	End If
	Temp=FKFun.SendMail("测试邮件标题"&Now(),"测试邮件内容"&Now(),EMail_Address,EMail_Accouns,EMail_Pwd,EMail_Smtp,EMail_To)
	Response.Write(Temp)
End Sub

Call FKFun.PageEnd()
%>
